package com.guaoran.interview.spring.source;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import javax.annotation.PostConstruct;

/**
 * @author : 孤傲然
 * @description : bean 生命周期
 * @date :2020/1/10 12:05
 */
@EnableTransactionManagement
@Service
public class BeanLifeCycleSource implements InitializingBean /*DisposableBean,*/ /*, BeanDefinitionRegistryPostProcessor*/ {
//    @Autowired
//    private SourceBean sourceBean;
//    @Resource
//    private SourceBean2 sourceBean2;

    @Autowired
    private SourceService sourceService;
    @Autowired
    private SourceService2 sourceService2;


    public BeanLifeCycleSource() {
        System.err.println("构造器-beanLifeCycle");
    }
//    @Override
//    public void destroy() throws Exception {
//        System.err.println("destroy");
//    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.err.println("afterPropertiesSet");
    }


    @PostConstruct
    public void init() {
        System.err.println("@PostConstruct");
    }

//    @PreDestroy
//    public void preDestroy() {
//        System.err.println("@PreDestroy");
//    }

//    @Override
//    public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
//        System.out.println("BeanDefinitionRegistryPostProcessor#postProcessBeanDefinitionRegistry");
//    }
//
//    @Override
//    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
//        System.out.println("BeanDefinitionRegistryPostProcessor#postProcessBeanFactory");
//    }
}
